<%@ page contentType="text/html; charset=utf-8"%>

<%@ include file="/WEB-INF/jsp/includeTop.jsp"%>
<%@ include file="/WEB-INF/jsp/includeTaglib.jsp" %>


<table width="100%" border="0" cellpadding="0" cellspacing="5">
	<tr>
		<td valign="top">
			<table class="dbborder" width="100%" border="0" cellpadding="0"
				cellspacing="0">
				<tr>
					<td valign="bottom" class="blueTableBg">&nbsp;下属工作跟踪&nbsp;-&nbsp;工作任务指派</td>
				</tr>
			</table>
		</td>
	</tr>
</table>

<div class="globalText" style="padding: 15px;border: solid 1px #999999;width: 768px;margin-left: 15px;" >
	<form id="assignForm" method="post" target="tempFrame" action="<c:url value='/subordinate/planAssign.html' />">
	<table class="globalText dbborder" width="100%" border="0" cellpadding="5" cellspacing="5" style="margin: 5px;">
        <tr>
            <td>所属项目</td>
            <td><input onclick="chooseProject();" readonly="readonly" id="projectCode"  type="text" class="txtbox required" size="20" /></td>
        </tr>
		<tr>
			<td>执行人</td>
			<td>
				<select id="selUserLoginName" class="globalText required" name="userLoginName">
					<option value="">请先选择项目</option>
				</select>
			</td>
		</tr>
		<tr>
			<td>终端信息</td>
			<td><input onclick="if($('#projectCode').val()==''){alert('请先选择项目');return;}chooseChannel();" readonly="readonly" id="storeCode"  type="text" class="txtbox required" size="20" /></td>
		</tr>
		<tr>
			<td>任务</td>
			<td><input onclick="if($('#projectCode').val()==''){alert('请先选择项目');return;}chooseTask();" id="jobId"  type="text" class="txtbox required" size="20" /></td>
		</tr>
		<tr>
			<td>任务日期 </td>
			<td>
				<input onclick="WdatePicker({minDate:'${nowDate}',dateFmt:'yyyy-MM-dd'});" type="text" id="planDate" name="planDate" class="txtbox required" size="20"  value=""/>
			</td>
		</tr>
		<tr>
			<td>开始时间</td>
			<td>
				<input id="startTime" class="required" name="startTime" onclick="WdatePicker({dateFmt:'HH:mm:ss',maxDate:'#F{$dp.$D(\'endTime\')}'});" style="width: 65px;" type="text" />
			</td>
		</tr>
		<tr>
			<td>截止时间</td>
			<td>
				<input id="endTime" class="required" name="endTime" onclick="WdatePicker({dateFmt:'HH:mm:ss',minDate:'#F{$dp.$D(\'startTime\')}'});" style="width: 65px;" type="text" />
			</td>
		</tr>

		<tr>
			<td colspan="2" ><input style="margin-left: 150px;" onclick="javascript:assignNameForNull();$('#assignForm').submit();" type="button" class=" btnStyle" value="提交" /></td>
		</tr>
	</table>

	<input type="hidden" name="projectCode" id="projectCodeValue" />
	<input type="hidden" name="storeCode" id="storeCodeValue"/>
	<input type="hidden" name="jobId" id="jobIdValue"/>
	</form>

	<input type="hidden" id="projectIdValue"/>
</div>

<script>

	var employeeUser=${employeeMap};

	function chooseProject(){
		var a=window.showModalDialog('<c:url value="/project/projectbrowserList.html" />',window,'status:no;resizable:no;directories:no;help:no;scroll:no;dialogWidth=660px;dialogHeight=360px;dialogLeft:500px;dialogTop:300px;');
	    var projectId=a.projectId;
	    var projectName=a.projectName;
	    var projectCode=a.projectCode;
	    $('#projectCode').val(projectName);
	    $('#projectCodeValue').val(projectCode);
	    $('#projectIdValue').val(projectId);


	    $('#selUserLoginName').empty();

        console.log(projectCode);
        console.log(JSON.stringify(employeeUser));
	    if(!employeeUser[projectCode]){
	    	alert("当前项目没有下属");
	    }
	    var users=employeeUser[projectCode];
	    for(var i in users){
	    	$('#selUserLoginName').append("<option value='"+users[i].loginName+"' >"+users[i].displayName+"</option>");
	    }
	}

	function chooseChannel(taskIndex){

		var a=window.showModalDialog('<c:url value="/channelList.html" />?projectId='+$('#projectIdValue').val(),window,'status:no;resizable:no;directories:no;help:no;scroll:no;dialogWidth=800px;dialogHeight=450px;dialogLeft:500px;dialogTop:300px;');
		$('#storeCode').val(a[1]);
		$('#storeCodeValue').val(a[0]);
	}

	function chooseTask(){
		var a=window.showModalDialog('<c:url value="/admin/jobList.html" />?projectId='+$('#projectIdValue').val(),window,'status:no;resizable:no;directories:no;help:no;scroll:no;dialogWidth=800px;dialogHeight=450px;dialogLeft:500px;dialogTop:300px;');
		$('#jobId').val(a.jobName);
		$('#jobIdValue').val(a.jobId);
	}

	function jobListOnloadCallBack(subWindow){
		var subDocument=subWindow.document;
		$(subDocument).find('.delBtn').each(function(i){
			$(this).hide();
		});
		$(subDocument).find('.chooseBtn').each(function(i){
			$(this).show();

			$(this).unbind("click");
			$(this).bind("click",function(){
				subWindow.parent.window.returnValue={jobName:$(this).attr("jobName"),jobId:$(this).attr("jobId")};
				subWindow.close();
			});
		});
		$(subDocument).find('.editBtn').each(function(i){
			$(this).hide();
		});
	}

    function submitCallbackSuccess(obj) {
        window.location = "<c:url value='/plan/taskList.html' />?from=subordinate&jobStatus=NOT_FINISHED";
    }
</script>


<script>
	$().ready(function() {
		var validate=$("#assignForm").validate({
			showErrors: customShowErrors,
			onfocusout:false,
			onkeyup:false,
			onclick:false
		});
	});
</script>

